package cn.edu.csust.cvs.management.controller;

import cn.edu.csust.cvs.management.common.ApiPageResult;
import cn.edu.csust.cvs.management.common.ApiResult;
import cn.edu.csust.cvs.management.controller.request.UserStatsPageQueryRequest;
import cn.edu.csust.cvs.management.controller.request.VideoStatsPageQueryRequest;
import cn.edu.csust.cvs.management.repository.entity.UserStatsView;
import cn.edu.csust.cvs.management.repository.entity.VideoStatsView;
import cn.edu.csust.cvs.management.service.StatsService;
import cn.edu.csust.cvs.management.service.domain.ClipStats;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;


/**
 * @Auther: snail
 * @Date: 2021/1/22 00:30
 * @Description: 审计管理控制器
 */
@RestController
@RequestMapping("/cvsm/stats")
@Api(tags = "审计管理")
public class StatsController {

    @Autowired
    StatsService statsService;

    @ApiOperation(value = "用户操作统计分页查询", notes = "分页查询视频列表")
    @GetMapping("/user")
    public ApiPageResult<List<UserStatsView>> pageQuery(@Valid UserStatsPageQueryRequest request, BindingResult result) {

        return statsService.pageQuery(request);
    }

    @ApiOperation(value = "视频操作统计分页查询", notes = "分页查询视频列表")
    @GetMapping("/video")
    public ApiPageResult<List<VideoStatsView>> pageQuery(@Valid VideoStatsPageQueryRequest request, BindingResult result) {

        return statsService.pageQuery(request);
    }

    @ApiOperation(value = "统计视频片段编辑信息", notes = "统计视频片段编辑信息")
    @GetMapping("/clip/{videoId}")
    public ApiResult<List<ClipStats>> pageQuery(@PathVariable("videoId") Integer videoId) {

        return statsService.statsVideoClip(videoId);
    }

}
